using System;
using System.Net;

namespace Kiva7.Utilities
{
    public class PostDataHelper
    {
        public void Upload(int lenderId, int donation)
        {

            WebClient webClient = new WebClient();

            webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

            var uri = new Uri("http://www.kiva.org/basket/set", UriKind.Absolute);

            PostDataBuilder postData = new PostDataBuilder();

            postData.Add("loans", "");
            postData.Add("donation", donation.ToString());
            postData.Add("app_id", "");

            webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();

            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);

            webClient.UploadProgressChanged += webClient_UploadProgressChanged;

            webClient.UploadStringAsync(uri, "POST", postData.ToString());

        }

        public void webClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        { }

        void webClient_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
        {
        }
    }
}